
********************************************************* 
** Stata code to construct Tables 2 and 4 in main text **
********************************************************* 

global stataout [specify local folder for figures and tables]

run "$stata\CAFC_Reg_Prep.do"
global seed 20220518
global ctrvar emp_ln ppe_per_inh revt_per_inh xrd_per_inh tobin ///
	   nclaims_ln  nciting_inh   

**Main specification: Commercial value
***Table 2. Main results 
global fe year##nclass_ocl##sic2 circuit 
global reps 1000

use "Patreg.dta", clear
get_coef "reghdfe xi_ln CAFC_post CAFC_post_prod CAFC_prod $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "reghdfe xi_ln CAFC_post CAFC_post_prod CAFC_prod $ctrvar if manuf == 1"
bstat, stat(coef) 
lincom   _b_CAFC_post +_b_CAFC_post_prod

use "Patreg.dta", clear
get_coef "reghdfe xi_ln CAFC_post CAFC_post_proc CAFC_proc $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "reghdfe xi_ln CAFC_post CAFC_post_proc CAFC_proc $ctrvar if manuf == 1"
bstat, stat(coef) 
lincom   _b_CAFC_post +_b_CAFC_post_proc



***********
**Table 2**
***********

use "Patreg.dta", clear
get_coef "reghdfe xi_ln CAFC_post  $ctrvar if manuf  == 1 "
simulate _b, reps($reps) seed($seed): ///
tse_boot "reghdfe xi_ln CAFC_post $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
outreg2 using "table2", word replace nor2 noobs  /// 
	  addtext("Year-Technology-Industry FE", ///
	"Yes", "Circuit FE", "Yes") ///
	addstat( "Patents", nobs, ///
	  "Companies", cmp, "R-squared", rsq, ///
	  "Economic effect", perct) ///
	  sortvar(_b_CAFC_post  _b_emp_ln _b_revt_per_inh _b_ppe_per_inh _b_xrd_per_inh ///
	_b_tobin  _b_nclaims   _b_nciting_inh  ///
	  _b_cons) bdec(3) tdec(3)  ///
	  ctitle("All")  
	  
use "Patreg.dta", clear
get_coef "reghdfe xi_ln CAFC_post CAFC_post_prod CAFC_prod $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "reghdfe xi_ln CAFC_post CAFC_post_prod CAFC_prod $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
reg_out "table2" "Effectiveness: Product"

use "Patreg.dta", clear
get_coef "reghdfe xi_ln CAFC_post CAFC_post_proc CAFC_proc $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "reghdfe xi_ln CAFC_post CAFC_post_proc CAFC_proc $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
reg_out "table2" "Effectiveness: Process"

use "Patreg.dta", clear
get_coef "ppmlhdfe cites_others CAFC_post $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "ppmlhdfe cites_others CAFC_post $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
reg_out_count "table2" "Forward citations"

use "Patreg.dta", clear
get_coef "ppmlhdfe nbodyonly CAFC_post $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "ppmlhdfe nbodyonly CAFC_post $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
reg_out_count "table2"  "Citations to science"

use "Patreg.dta", clear
get_coef "ppmlhdfe pat_wrd_min CAFC_post $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "ppmlhdfe pat_wrd_min CAFC_post $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
reg_out_count "table2" "Independent claims"


***********
**Table 4**
***********
use "Patreg.dta", clear
get_coef "reghdfe xi_ln CAFC_post cites_others $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "reghdfe xi_ln CAFC_post cites_others $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
outreg2 using "table4", word replace nor2 noobs  /// 
	  addtext("Year-Technology-Industry FE", ///
	"Yes", "Circuit FE", "Yes") ///
	addstat( "Patents", nobs, ///
	  "Companies", cmp, "R-squared", rsq, ///
	  "Economic effect", perct) ///
	  sortvar(_b_CAFC_post  _b_emp_ln _b_revt_per_inh _b_ppe_per_inh _b_xrd_per_inh ///
	_b_tobin  _b_nclaims   _b_nciting_inh  ///
	  _b_cons) bdec(3) tdec(3)  ///
	  ctitle("Forward citations")  

use "Patreg.dta", clear
get_coef "reghdfe xi_ln CAFC_post nbodyonly $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "reghdfe xi_ln CAFC_post nbodyonly $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
reg_out "table4" "Science citations"

use "Patreg.dta", clear
get_coef "reghdfe xi_ln CAFC_post pat_wrd_min $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "reghdfe xi_ln CAFC_post pat_wrd_min $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
reg_out "table4" "Patent scope"

use "Patreg.dta", clear
get_coef "reghdfe xi_ln CAFC_post phd_ct_perm  $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "reghdfe xi_ln CAFC_post phd_ct_perm  $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
reg_out "table4" "Scientific progress"

use "Patreg.dta", clear
get_coef "reghdfe xi_ln CAFC_post rd_ct_percapita  $ctrvar if manuf  == 1"
simulate _b, reps($reps) seed($seed): ///
tse_boot "reghdfe xi_ln CAFC_post rd_ct_percapita  $ctrvar if manuf == 1"
bstat, stat(coef) 
cd "$stataout"
reg_out "table4" "R&D"
